import axios from 'axios'

const api = axios.create({
  baseURL: 'http://localhost:8000/api'
})

export const templateAPI = {
  getAll: () => api.get('/templates/'),
  create: (data) => api.post('/templates/', data),
  update: (id, data) => api.put(`/templates/${id}/`, data),
  delete: (id) => api.delete(`/templates/${id}/`),
  getExperiments: () => api.get('/templates/experiments/'),
  getExperimentInfo: (experimentId) => api.get(`/templates/experiment_info/?experiment_id=${experimentId}`),
  getExperimentChannels: (experimentId) => api.get(`/templates/experiment_channels/?experiment_id=${experimentId}`)
}

export const dataAPI = {
  getData: (params) => api.get('/data/get_data/', { params }),
  getAll: () => api.get('/data/')
}

export const logAPI = {
  getAll: () => api.get('/logs/'),
  getParameters: (params) => api.get('/logs/get_parameters/', { params }),
  getImages: (params) => api.get('/logs/get_images/', { params })
}

export const curveAPI = {
  getCurveData: (data) => api.post('/curve/get_curve_data/', data),
  getChannelInfo: (experimentId) => api.get(`/curve/get_channel_info/?experimentId=${experimentId}`),
  saveChartImage: (data) => api.post('/curve/save-image/', data)
} 